<script type="text/javascript" src="{baseUrl}/public/js/jquery.md5.js"></script>

<h2><?php echo $this->translate( 'my_account' ) ?></h2>
<?php if( !$this->userData ) { ?>

<?php echo $this->inlineScript()->setScript('
	$(document).ready(function(){
		$.validator.setDefaults({
			submitHandler: function(e) { 
				var fields = $(e).find( "input.style1" );
				
				$("#login-form5").animate({
					opacity: 0
				});
				
				$.post(
					baseUrl + "/index/login",
					{
						login : $( "#log_mail" ).val(),
						password : $.md5( $("#log_pass" ).val() ),
						json : true
					},
					function( resp ){
						if( resp.status ) {
							window.location.reload();
						} else {
							alert( "' . $this->translate( 'error_login' ) . '" );
							$("#login-form5").animate({
								opacity: 1
							});
						}
					},
					"json"
				);
			}
		});
	
		$("#form1log").validate({
			rules: {
				email : {
					required: true,
					email: true
				},
				pass : {
					required: true,
					minlength: 2
				}
			},
			messages: {
				email : "' . $this->translate( 'error_email' ) . '",
				pass : "'. $this->translate( 'error_password' ) .'"
			}
		});
	});
	') ?>
	
<div class="box nomtop " id="login-form5">

<h1><?php echo $this->translate( 'shop_bon_logowanie' ); ?></h1>

<form id="form1log" method="post" action="">
<table class="tab">
	<tr>
		<td class="aright"><?php echo $this->translate( 'shop_bon_login' ); ?>:</td>
		<td><input type="text" name="email" id="log_mail" value="" class="type5"></td>
	</tr>
	<tr>
		<td class="aright"><?php echo $this->translate( 'shop_bon_pass' ); ?>:</td>
		<td><input type="password" name="password" id="log_pass" value="" class="type5"></td>
	</tr>
</table>
</form>

<div class="line" style="margin:10px 0"></div>

<div class="acenter">
<a href="javascript:;" class="button" onclick="$('#form1log').submit()"><?php echo $this->translate( 'shop_bon_logowanie' ); ?></a>
</div>

<div class="acenter" style="margin-top:20px">
<p>

	<a href="{baseUrl}/index/newaccount" class="orange"><?php echo $this->translate( 'basket_newaccount' ) ?></a> <span style="margin:0 10px">/</span> <a href="{baseUrl}/index/remindpass"><?php echo $this->translate( 'basket_remind' ) ?></a></p>
</div>

<div class="end"></div>

	
</div>
<?php } else { ?>
<div class="box boxprofile">
	
	<div class="menu">
		<div class="acenter">
			<a href="{baseUrl}/shop/account" class="button prodmenu"><?php echo $this->translate( 'my_details' ) ?></a>
			<a href="{baseUrl}/shop/orders" class="button prodmenu buttonactive"><?php echo $this->translate( 'my_orders' ) ?></a>
			<a href="{baseUrl}/shop/observed" class="button prodmenu"><?php echo $this->translate( 'my_observed' ) ?></a>
			<a href="{baseUrl}/shop/vouchers" class="button prodmenu"><?php echo $this->translate( 'my_vouchers' ) ?></a>
		</div>
	</div>
	
	<table class="tab2">
	<tr>
		<th><?php echo $this->translate( 'order_nr' ); ?></th>
		<th><?php echo $this->translate( 'order_date' ); ?></th>
		<th><?php echo $this->translate( 'order_value' ); ?></th>
		<th><?php echo $this->translate( 'order_status' ); ?></th>
		<th><?php echo $this->translate( 'order_fv' ); ?></th>
	</tr>
	
	<?php if( $this->emptyResult ) { ?>
		<tr>
			<td colspan="5"><?php echo $this->translate( 'empty_result_orders' ); ?></td>
		</tr>
	<?php } else { ?>
		<?php foreach( $this->list as $value ) { ?>
			<tr>
				<td><?php echo $value['o_id'] ?></td>
				<td><?php echo $value['add_date'] ?></td>
				<td><?php echo $this->Numberformat($value['price']) . ' ' . $value['currency']; ?></td>
				<td><?php echo ( $value['state4'] > 0 ) ? $this->translate( 'order_send' ) : $this->translate( 'order_not_send' ); ?></td>
				<td>
				<?php if($value['state']==1) { ?>
				<a href="{baseUrl}/shop/orders/fav/<?php echo $value['o_id'] ?>" >POBIERZ</a>
				<?php } else {?>
					
					<?php if($value['vouchers_v_id']>0){ ?>
					-
					<?php } else {?>
					<a href="{baseUrl}/shop/orders/proforma/1/fav/<?php echo $value['o_id'] ?>" >POBIERZ</a>
					<?php }?>
					
				<?php } ?>
				</td>
			</tr>
		<?php } ?>
	<?php } ?>
	
	</table>
	<div class="end"></div>
</div>
<?php } ?>